package com.linwen.javase.desgin_pattern.BigTalkDesignPattenJAVACode._05工厂方法模式._2计算器;

import java.util.Optional;

/**
 * @ClassName OperationFactory
 * @Description TODO
 * @Author zero
 * @DATE 2023/7/12 1:10 PM
 * @Version 1.0
 */
public class OperationFactory {
    public static Operation createOperate(String strOperate) {
        IFactory factory = null;
        switch (strOperate){
            case "+":
                factory = new AddFactory();
                break;
            case "-":
                factory = new SubFactory();
                break;
            case "*":
                factory = new MulFactory();
                break;
            case "/":
                factory = new DivFactory();
                break;
        }
        return factory.createOperation();
    }
}
